var Header = {
	timer: {
		
	},
	offset: {
		},
	numFrames: 29,
	speed: 20,
	filterNav: '',

	init: function() {
		Header.filterNav = $('#navigation');
		Header.filterNav.children().children().bind('click', River.onFilterItems);
		$('.sequence').bind('mouseenter', this.onNavItemOver);
		$('.sequence').bind('mouseleave', this.onNavItemOut);

		if(River.support3d == true) {
			$('.nav-side3').show();
		}

		this.animateTop();
	},

	animateTop: function() {
		if(River.support3d == true) {
			$('.nav-side2').addClass('nav-side2-3d');
		}

		var numPages = $('.pages').children().length;
		var i = 0;

		while(i < numPages) {
			(function(n) {
				setTimeout(function() {
					if(River.support3d == true) {
						$('.pages').children().eq(n).find('.nav-inner').addClass('nav-inner-90');	
					}
				}, n * 400);
			})(i);

			i++;
		}

		$('.pages').children().bind('mouseenter', Header.onPageItemOver);
		$('.pages').children().bind('mouseleave', Header.onPageItemOut);
	},

	onPageItemOver: function(event) {
		if(River.support3d == true) {
			$(this).find('.nav-inner').addClass('nav-inner-180');
		} else {
			$(this).find('.nav-inner').find('.nav-side2').addClass('nav-side2-over');
		}
	},

	onPageItemOut: function(event) {
		if(River.support3d == true) {
			$(this).find('.nav-inner').removeClass('nav-inner-180');
		} else {
			$(this).find('.nav-inner').find('.nav-side2').removeClass('nav-side2-over');
		}
	},
	
	onNavItemOver: function(event) {
		var $self = $(this);
		var className = this.parentNode.className;
		Header.stopTimer(className);
		var i = parseInt($(this).attr('data-i'));
		
		
		$self.siblings('.tooltip-container').show(100, function(){
			$self.next().children().addClass('tooltip-over');
		});
			
		var timer = function() {
			if(i < Header.numFrames) {
				var pos = i * -41;
				$self.css({
					backgroundPosition: pos+'px '+offset
				});

				i++;
				$self.attr('data-i', i);

				if(i == (Header.numFrames - 1)) {
					Header.stopTimer(className);
				}
			}
			
		}

		if(!$self.hasClass('active')) {	
			switch(className) {
				}
		}
	},

	onNavItemOut: function(event) {
		var $self = $(this);
		var className = this.parentNode.className;
		$self.next().children().removeClass('tooltip-over');

		if(!$self.hasClass('active')) {
			Header.animateNavRollout($self, className);
		}
		$self.siblings('.tooltip-container').hide();
	},

	animateNavRollout: function(el, className) {
		Header.stopTimer(className);
		var i = parseInt($(el).attr('data-i'));

		var timer = function() {
			if(i >= 0) {
				var pos = i * -41;
				el.css({
					backgroundPosition: pos+'px '+offset
				});

				i--;
				el.attr('data-i', i);

				if(i == 0) {
					Header.stopTimer(className);
				}
			}

		};

		switch(className) {
			
		}
	},

	stopTimer: function(className) {
		switch(className) {
			}
	}
};